package com.anysoft.web;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.webkit.WebView;

import com.anysoft.R;
import com.anysoft.base.BaseWebviewWithCacheActivity;
import com.anysoft.utils.MentorLogger;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import butterknife.OnClick;

/**
 * Created by wwq on 2017/3/16.
 */

public class RegistrationProcessActivity extends BaseWebviewWithCacheActivity {

    private String head,detailContent;
    private String shareUrl;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        title.setText("开户指引");
        shareButtonTitle1.setVisibility(View.VISIBLE);
        head = "点击开启你的专属财富快线";
        detailContent = "稳健投资, XXXXXX~";
        shareUrl = "https://wx.icbccs.com.cn/GY_H5/icbcFund306/registrationProcess.html";
//        shareUrl = "https://ydxjb.icbccs.com.cn/GY_H5/icbcFund308/registrationProcess.html";
//        shareUrl = HostConstant.HOST_WEB_URL_HEADER + "registrationProcess.html";
        loadUrl = "file:///android_asset/html/registrationProcess.html";
        initView(loadUrl);
//        SharePopup.setOnShareEventLinstener(new OnShareEventLinstenerImpl() {
//            @Override
//            public void onShareSuccess() {
//                AnalyticsEventUtils.toShareRegisterProcessEvent(RegistrationProcessActivity.this);
//            }
//        });
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
    }


    @Override
    public void onshouldOverrideUrlLoadingCallBack(WebView webview, String url) {
        String url_decode = null;
        try {
            url_decode = URLDecoder.decode(url, "utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        MentorLogger.Log(TAG, "url_decode=" + url_decode);
        if (url.contains("index.html")) {
            finish();
        } else {
            webview.loadUrl(url);
        }
    }

    @OnClick({R.id.shareButtonTitle1})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.shareButtonTitle1:
//                SharePopup.Share(mActivity, "" + head, shareUrl, detailContent);
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
